# -*- encoding: utf-8 -*-
"""
@version: 1.0
@author: yang ming
@contact: 122162005@qq.com
@site: http://www.idianjia.com/
@software: PyCharm
@file: phone_validator.py
@time: 2016/3/22 10:12
"""
import re

from django.core.validators import ValidationError


def validate_phone(value):
    comp = re.compile(r'^[\d_]{1,11}$')
    if comp.match(value) is None:
        raise ValidationError("please enter a phone number")


if __name__ == "__main__":
    validate_phone("15388128692")
